<?
//set the session laivID - if requested
if (isset($_REQUEST['laivID'])) {
	$id = $_REQUEST['laivID'];
	
	if (!is_numeric($id)) 
		die("Erronous laivID");

	$sql = "SELECT * FROM laiv WHERE ID=$id AND Offentlig=1";
	$laivs = mysql_query($sql);

	if (mysql_num_rows($laivs) == 1) {
		$_SESSION['laivID'] = $id;
		session_unregister('AuthStatus');
	} else {
		die("Erronous laivID");
	}
} elseif (!isset($_SESSION['laivID'])) {
	die("No laivID");
}

function getLaiv() {
	$sql = "SELECT *, NOW() > Pamelding_start AS pam_Startet, NOW() > Pamelding_slutt AS pam_Sluttet  FROM Laiv WHERE ID=".$_SESSION['laivID'];
	$retur = mysql_query($sql);

	if (mysql_num_rows($retur) == 1) {
		$data = mysql_fetch_assoc($retur);
		return $data;
	} else {
		return null;
	}
}
?>
